package com.hq.fxh.No5_User.Jianli.Activity;

import android.content.Intent;
import android.net.Uri;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hq.fxh.No0_ChengQu.Activity.BaseActivity;
import com.hq.fxh.No5_User.Jianli.Fragment.Fragment_JianLi_AddEducation;
import com.hq.fxh.No5_User.Jianli.Fragment.Fragment_JianLi_AddWork;
import com.hq.fxh.No5_User.Jianli.Fragment.Fragment_JianLi_QiuZhiYIXiang;
import com.hq.fxh.No5_User.Jianli.Fragment.Fragment_JianLi_XinxiSet;
import com.hq.fxh.R;
import com.hq.fxh.Utils.LogUtils;

/**
 * /**
 *
 * @author 薛
 * @ClassName
 * @Description :
 * @Created 2017/9/21
 * @Email xlwenhao1858@sina.com
 */


public class JianLiSet extends BaseActivity implements View.OnClickListener {


    protected ImageView toolbarImageBack;
    protected LinearLayout toolbarLayoutBack;
    protected TextView toolBarTvTitle;
    protected TextView toolBarTvMore;
    protected LinearLayout toolbarLayoutMore;
    protected FrameLayout fragmentJianliset;
    int type;
    private Fragment_JianLi_AddEducation educationFragment;
    private Fragment_JianLi_AddWork workFragment;
    private Fragment_JianLi_XinxiSet xinxiFragment;
    private Fragment_JianLi_QiuZhiYIXiang qiuZhiFragment;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_jianli_set;
    }



    @Override
    protected void initView() {
        toolbarImageBack = (ImageView) findViewById(R.id.toolbar_image_back);
        toolbarLayoutBack = (LinearLayout) findViewById(R.id.toolbar_Layout_back);
        toolbarLayoutBack.setOnClickListener(JianLiSet.this);
        toolBarTvTitle = (TextView) findViewById(R.id.toolBar_tv_Title);
        toolBarTvMore = (TextView) findViewById(R.id.toolBar_tv_More);
        toolbarLayoutMore = (LinearLayout) findViewById(R.id.toolbar_Layout_More);
        toolbarLayoutMore.setOnClickListener(JianLiSet.this);
        fragmentJianliset = (FrameLayout) findViewById(R.id.fragment_jianliset);

    }

    @Override
    protected void initData() {

        FragmentManager manager = getSupportFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();

        Intent intent = getIntent();
        type = intent.getIntExtra("type", -1);
        String data = intent.getStringExtra("data");



        toolBarTvMore.setText("保存");
        LogUtils.e("type==" + type);
        switch (type) {
            case 0:
                toolBarTvTitle.setText("基本信息");
                xinxiFragment = new Fragment_JianLi_XinxiSet();
                xinxiFragment.setData(data);
                transaction.add(R.id.fragment_jianliset, xinxiFragment);
                transaction.commit();
                break;
            case 1:
                toolBarTvTitle.setText("工作经历");
                workFragment = new Fragment_JianLi_AddWork();
                workFragment.setData(data);

                transaction.add(R.id.fragment_jianliset, workFragment);
                transaction.commit();
                break;
            case 2:
                toolBarTvTitle.setText("教育经历");
                educationFragment = new Fragment_JianLi_AddEducation();
                educationFragment.setData(data);
                transaction.add(R.id.fragment_jianliset, educationFragment);
                transaction.commit();
                break;
            case 3:
                toolBarTvTitle.setText("教育经历");
                qiuZhiFragment = new Fragment_JianLi_QiuZhiYIXiang();
                transaction.add(R.id.fragment_jianliset, qiuZhiFragment);
                transaction.commit();
                break;
        }

    }


    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.toolbar_Layout_back) {
            finish();

        } else if (view.getId() == R.id.toolbar_Layout_More) {
            clickBaoCun();
            finish();
        }
    }

    public void clickBaoCun() {
        finish();

    }


}
